﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using CTTest.Essential;
using CTTest.Essential.Soap.BMS;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace CTTest
{
    /// <summary>
    /// 9.1.2 业务订购退订接口
    /// </summary>
    public partial class CTTestMain
    {
        private static readonly string 有效SPID = "0001";
        private static readonly string 有效内容编号 = "0001";
        private static readonly string 有效产品编号 = "0001";
        private static readonly string 有效营销品编号 = "0001";
        private static readonly string 订购代码 = "1";
        private static readonly string 退订代码 = "2";
        //private static readonly string 客户端代码 = "1";
        //private static readonly string WAP代码 = "2";

        [TestMethod]
        [Description("业务订退--订退产品场景测试")]
        public void 业务订退の订退产品()
        {
            WriteLogger("Entering test method {0}", MethodBase.GetCurrentMethod().Name);

            dynamic e;

            //登录
            var flag = CtcUtil.TestLogin(new LoginReq
            {
                UserID = 有效号码,
                Action = 登录代码,
            }, WriteLogger, out e);
            Assert.IsTrue(flag, "用户登录失败");

            //订购
            flag = CtcUtil.TestInstantSubscribe(new InstantSubscribeRequest
            {
                SpID = 有效SPID,
                UserID = 有效号码,
                UserToken = e.UserToken,
                ContentID = 有效内容编号,
                ProductID = 有效产品编号,
                Action = 订购代码,
            }, WriteLogger);
            Assert.IsTrue(flag, "产品订购失败");

            //退订
            flag = CtcUtil.TestInstantSubscribe(new InstantSubscribeRequest
            {
                SpID = 有效SPID,
                UserID = 有效号码,
                UserToken = e.UserToken,
                ContentID = 有效内容编号,
                ProductID = 有效产品编号,
                Action = 退订代码,
            }, WriteLogger);
            Assert.IsTrue(flag, "产品退订失败");

            WriteLogger("Leaving test method {0}", MethodBase.GetCurrentMethod().Name);
        }


        [TestMethod]
        [Description("业务订退--订退营销品场景测试")]
        public void 业务订退の订退营销品()
        {
            WriteLogger("Entering test method {0}", MethodBase.GetCurrentMethod().Name);

            dynamic e;

            //登录
            var flag = CtcUtil.TestLogin(new LoginReq
            {
                UserID = 有效号码,
                Action = 登录代码,
            }, WriteLogger, out e);
            Assert.IsTrue(flag, "用户登录失败");

            //订购
            flag = CtcUtil.TestInstantSubscribe(new InstantSubscribeRequest
            {
                SpID = 有效SPID,
                UserID = 有效号码,
                UserToken = e.UserToken,
                ContentID = 有效内容编号,
                PromotionID = 有效营销品编号,
                Action = 订购代码,
            }, WriteLogger);
            Assert.IsTrue(flag, "营销品订购失败");

            //退订
            flag = CtcUtil.TestInstantSubscribe(new InstantSubscribeRequest
            {
                SpID = 有效SPID,
                UserID = 有效号码,
                UserToken = e.UserToken,
                ContentID = 有效内容编号,
                ProductID = 有效产品编号,
                Action = 退订代码,
            }, WriteLogger);
            Assert.IsTrue(flag, "营销品退订失败");

            WriteLogger("Leaving test method {0}", MethodBase.GetCurrentMethod().Name);
        }
    }
}
